//
//  GAOEmoticonButton.swift
//  Weibo28
//
//  Created by 高辰 on 16/5/21.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class GAOEmoticonButton: UIButton {

    var dataModel: GAOEmoticonModel? {
        didSet {
            guard let model = dataModel else {
                return
            }
            
            // 表情类型 0->图片 , 1->emoji
            if model.type == "0" {
                self.setImage(UIImage(named: model.imagePath!), forState: .Normal)
                //如果类型是图片,就把title设为nil
                self.setTitle(nil, forState: .Normal)
                
            }else {
                //emoji
                self.setTitle((model.code! as NSString).emoji(), forState: .Normal)
                self.titleLabel?.font = UIFont.systemFontOfSize(34)
                //如果类型是emoji,就把图片设为nil
                self.setImage(nil, forState: .Normal)
            }

        }
    
    }

}
